{{Extend "layout"}}
{{Block "title"}}{{if HasSuffix URL.Path "_add"}}{{"添加等级"|T}}{{else}}{{"修改等级"|T}}{{end}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li><a href="__BACKEND__/official/agent_level_index">{{"代理等级"|T}}</a></li>
<li class="active">{{if HasSuffix URL.Path "_add"}}{{"添加"|T}}{{else}}{{"修改"|T}}{{end}}</li>
{{/Block}}
{{Block "main"}}
<div class="row">
    <div class="col-md-12">
        <div class="block-flat">
          <div class="header">							
            <h3>{{if HasSuffix URL.Path "_add"}}{{"添加等级"|T}}{{else}}{{"修改等级"|T}}{{end}}</h3>
          </div>
          <div class="content">
              <form class="form-horizontal group-border-dashed" parsley-validate novalidate method="POST" action="">
              <div class="form-group">
                <label class="col-sm-2 control-label">{{"等级名称"|T}}</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" required name="name" value="{{Form "name"}}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">{{"代理费"|T}}</label>
                <div class="col-sm-3">
                    <input type="number" class="form-control" name="agencyFee" value="{{Form "agencyFee"}}" min="0.00" placeholder="0.00">
                </div>
                <label class="col-sm-2 control-label">{{"下级代理费抽成比例"|T}}</label>
                <div class="col-sm-3">
                    <input type="number" class="form-control" name="agencyFeeRebateRatio" value="{{Form "agencyFeeRebateRatio"}}" min="0" max="1" step="0.001" placeholder="0.000">
                    <div class="help-block">{{"取值范围"|T}}: 0.000~1.000</div>
                </div>
              </div>
              {{$end := Sub (len Stored.levelList) 1}}
              {{range $k,$v := Stored.levelList}}
              {{if Eq (Math "mod" $k 2) 0}}
              {{if gt $k 0}}
              </div><!-- /.form-group -->
              {{end}}
              <div class="form-group">
              {{end}}
                <label class="col-sm-2 control-label">{{T "%d级下线分成" $v}}</label>
                <div class="col-sm-3">
                    <input type="number" class="form-control" name="salesCommissionRatio{{$v}}" value="{{Form (printf "salesCommissionRatio%d" $v)}}" min="0" max="1" step="0.001" placeholder="0.000">
                    <div class="help-block">{{"取值范围"|T}}: 0.000~1.000</div>
                </div>
              {{if Eq $k $end}}
              </div><!-- /.form-group -->
              {{end}}
              {{end}}
              <div class="form-group">
                <label class="col-sm-2 control-label">{{"说明"|T}}</label>
                <div class="col-sm-8">
                  <textarea class="form-control" name="description" parsley-trigger="keyup" parsley-maxlength="255" parsley-validation-threshold="10">{{Form "description"}}</textarea>
                </div>
              </div>
              <div class="form-group form-submit-group">
									<div class="col-sm-9 col-sm-offset-2">
									  <button type="submit" class="btn btn-primary btn-lg"><i class="fa fa-save"></i> {{"保存"|T}}</button>
									  <button type="reset" class="btn btn-default btn-lg"><i class="fa fa-refresh"></i> {{"重置"|T}}</button>
									</div>
							</div>
            </form>
          </div><!-- /.content -->
        </div><!-- /.block-flat -->
    </div>
</div>
{{/Block}}
{{Block "footer"}}
<script src="__ASSETS__/js/selectpage/selectpage.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
  $('#productId').selectPage({
    showField : 'name',
    keyField : 'id',
    data : BACKEND_URL+'/official/pay/product_index',
    params : function(){return {};},
    eAjaxSuccess : function(d){
        var result;
        if(d) result = {
          "list":d.Data.listData,
          "pageSize": d.Data.pagination.limit,
          "pageNumber": d.Data.pagination.page,
          "totalRow": d.Data.pagination.rows,
          "totalPage":d.Data.pagination.pages
        };
        else result = undefined;
        return result;
    }
});
});
</script>
{{/Block}}